package com.edou.member.controller.weixin;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.edou.base.controller.BaseController;
import com.edou.member.entity.MemberUser;
import com.edou.member.form.MemberUserForm;
import com.edou.member.service.IMemberUserService;

/**
 * 会员首页模块
 * @creator     admin
 * @create-time 2016/3/12 16:10:22
 * @email admin@edou.com
 * @company www.edou.com
 * @version 1.0
 */
@Controller("memberUserRegistWeixinController")
@Scope("prototype")
@RequestMapping("/weixin/member")
public class MemberUserRegistWeixinController extends BaseController {

	@Resource(name = "memberUserServiceImpl")
	private IMemberUserService memberUserService;
	
	/**
	 * 注册验证：帐号唯一性验证
	 * @return 
	 */
	@RequestMapping(value = "/check_account.htm", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView checkAccount(MemberUserForm model){
		String account = model.getAccount();
		MemberUser member = memberUserService.getMemberUserByAccount(account);
		if (null == member) {
			return ajaxJSON(Status.success,"true");
		} else {
			return ajaxJSON(Status.success,"false");
		}
	}
	
	/**
	 * 注册验证：邮箱唯一性验证
	 * @return 
	 */
	@RequestMapping(value = "/check_email.htm", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView checkEmail(MemberUserForm model){
		String email = model.getEmail();
		MemberUser member = memberUserService.getMemberUserByEmail(email);
		if (null == member) {
			return ajaxJSON(Status.success,"true");
		} else {
			return ajaxJSON(Status.success,"false");
		}
	}
	
	/**
	 * 注册验证：手机唯一性验证
	 * @return 
	 */
	@RequestMapping(value = "/check_mobile.htm", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView checkMobile(MemberUserForm model){
		String mobile = model.getMobile();
		MemberUser member = memberUserService.getMemberUserByMobile(mobile);
		if (null == member) {
			return ajaxJSON(Status.success,"true");
		} else {
			return ajaxJSON(Status.success,"false");
		}
	}
	
}